package com.yeyks.app.controller.base.vip;

import com.yeyks.common.ajax.AjaxResponseBody;
import com.yeyks.common.constants.ConfigKey;
import com.yeyks.commonReference.service.config.ConfigService;
import com.yeyks.commonReference.service.consumer.MemberCardService;
import com.yeyks.consumer.param.MemberCardCheckParam;
import com.yeyks.consumer.param.MemberCardTypeParam;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author fuchangshuai
 * @date 2019/3/26 4:27 PM
 */
@Api(tags = "会员卡接口", description = "会员卡(token放入请求头中，名字为headerToken)")
@Slf4j
@RestController
@RequestMapping(value = "/app/member/card")
public class MemberCardController {

    @Autowired
    private MemberCardService memberCardService;
    @Autowired
    private ConfigService configService;

    @ApiOperation(value = "检查卡是否已出售:v3.6", notes = "检查卡是否已出售")
    @PostMapping(value = "/check")
    public AjaxResponseBody<Boolean> checkCardEnable(@Validated MemberCardCheckParam param) {
        return AjaxResponseBody.success(memberCardService.checkCardEnable(param));
    }

    /**
     * 获取会员权益
     *
     * @return
     */
    @ApiOperation(value = "获取vip会员权益:v3.5", notes = "获取会员权益")
    @PostMapping(value = "/advantage")
    public AjaxResponseBody<Object> advantage(MemberCardTypeParam param) {
        return AjaxResponseBody.success(memberCardService.advantage(param));
    }

    /**
     * 获取钱包说明
     *
     * @return
     */
    @ApiOperation(value = "获取vip钱包说明:v3.5", notes = "获取钱包说明")
    @PostMapping(value = "/wallet/desc")
    public AjaxResponseBody<Object> walletDesc(MemberCardTypeParam param) {
        return AjaxResponseBody.success(memberCardService.walletDesc(param));
    }

    // v3.4.a
    @ApiOperation(value = "vip买卡说明:v3.4.a", notes = "买卡说明:v3.4.a")
    @PostMapping(value = "/activity/buyCard")
    public AjaxResponseBody<String> buyCard() {
        String value = configService.getValue(ConfigKey.VIP_CARD_ACTIVITY_DETAILS);
        return AjaxResponseBody.success(value);
    }

}
